<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
	    <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">
        <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
        <link rel="stylesheet" type="text/css" href="easyui/themes/color.css">
        <script type="text/javascript" src="easyui/jquery.min.js"></script>
        <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
        <link rel="stylesheet" href="layui/css/layui.css" media="all">
        <script type="text/javascript" src="layui/layui.all.js"></script>
        <script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>
        <script type="text/javascript" src="easyui/plugins/datagrid-filter.js"></script>
    </head>
    <body>
         <table id="dat" class="easyui-datagrid" title="" data-options="fit:true,singleSelect:false,
                                                                   selectOnCheck:true,ctrlSelect:true,
                                                                   fitColumns:true,rownumbers:true,remoteFilter: true,
                                                                   pagination:true,clientPaging: false,
                                                                   collapsible:false,idField:'id',
                                                                   toolbar:toolbars,pageSize:20">
	        <thead>
	            <tr>
	                     <th data-options="field:'id',width:200,sortable:true,checkbox:true">ID</th>
	                     <th data-options="field:'uname',width:200,sortable:true">用户昵称</th>
	                     <th data-options="field:'mobile',width:200,sortable:true">手机号</th>
	                     <th data-options="field:'currency_title',width:200">币种名称</th>
	                     <th data-options="field:'user_addr',width:200">提币地址</th>
	                     <th data-options="field:'addr',width:200">接收地址</th>
	                     <th data-options="field:'amount',width:200,sortable:true">提币金额</th>
	                     <th data-options="field:'charge',width:200,sortable:true">手续费</th>
	                     <th data-options="field:'real_amount',width:200,sortable:true">实收金额</th>
	                     <th data-options="field:'result',width:200,sortable:true,formatter:showStatusTitle">状态</th>
	                     <th data-options="field:'txhash',width:200">hash</th>
	                     <th data-options="field:'reason',width:200">原因</th>
	                     <th data-options="field:'update_time',width:200,sortable:true">到账时间</th>
	                     <th data-options="field:'create_time',width:200,sortable:true">提币时间</th>
	            </tr>
	        </thead>
	        
	    </table>
	    <div id="form" style="width:100%;padding:30px 60px;"></div>
    </body>
    <script type="text/javascript">
		    var toolbars = [/* {
		        text:'新增',
		        iconCls:'icon-add',
		        handler:function(){
		        	$('#form').dialog({
		        	    title: '新增表单',
		        	    width: 500,
		        	    height: 380,
		        	    closed: false,
		        	    cache: false,
		        	    href: 'to?page=app/btRecord/form',
		        	    modal: true,
		        	    onClose:function(){
		        	    	$('#dat').datagrid('reload');
		        	    },
		        	    onDestroy:function(){
		        	    	$('#dat').datagrid('reload');
		        	    }
		        	});
		        }
		    },{
		        text:'修改',
		        iconCls:'icon-edit',
		        handler:function(){
		        	var data=$('#dat').datagrid('getSelected');
		        	if(data&&data.id){
		        		$('#form').dialog({
			        	    title: '修改表单',
			        	    width: 500,
			        	    height: 380,
			        	    closed: false,
			        	    cache: false,
			        	    href: 'app/btRecord/form?id='+data.id,
			        	    modal: true,
			        	    onClose:function(){
			        	    	$('#dat').datagrid('reload');
			        	    },
			        	    onDestroy:function(){
			        	    	$('#dat').datagrid('reload');
			        	    }
			        	});
		        	}else{
		        		layer.alert('请选择记录');
		        	}
		        }
		    },'-',{
		        text:'删除',
		        iconCls:'icon-remove',
		        handler:function(){
		        	var data=$('#dat').datagrid('getSelections');
		        	if(data&&data.length>0){
		        		layer.confirm('确定要删除码?',function(index){
		        			var key='';
		        			var ids='';
		        			if(data instanceof Array){
		        				$.each(data,function(index,value){
	                            	if(index>0){
	                            		ids+=',';
	                            	}
	                            	ids+=value.id;
	                            })
		        			}else{
		        				key=data.id;
		        			}
		        			
                            
                            
                            $.post('app/btRecord/delete',{'id':key,'ids':ids},function(r){
                            	if(r.code>0){
                            		layer.alert('删除失败',function(){
                            			layer.close(index);			
                            		});
                            	}else{
                            		layer.close(index);
                            		$('#dat').datagrid('reload');
                            	}
                            },"json")
		        			
		        		});
		        	}
		        }
		    }, */{
		        text:'审核通过',
		        iconCls:'icon-ok',
		        handler:function(){
		        	var data=$('#dat').datagrid('getSelected');
		        	if(data&&data.id){
		        		
		        		if(data.result>4){
		        			layer.alert('己处理过');
		        			return;
		        		}
		        		
		        		$('#form').dialog({
			        	    title: '审核通过',
			        	    width: 500,
			        	    height: 380,
			        	    closed: false,
			        	    cache: false,
			        	    href: 'app/btRecord/form?page=0&id='+data.id,
			        	    modal: true,
			        	    onClose:function(){
			        	    	$('#dat').datagrid('reload');
			        	    },
			        	    onDestroy:function(){
			        	    	$('#dat').datagrid('reload');
			        	    }
			        	});
		        	}else{
		        		layer.alert('请选择记录');
		        	}
		        }
		    },{
		        text:'全部通过',
		        iconCls:'icon-ok',
		        handler:function(){
		        	var ids='';
		        	var datas=$('#dat').datagrid('getSelections');
		        	if(datas&&datas.length>0){
		        		
		        		$.each(datas,function(index,data){
		        			if(ids.length>0){
		        				ids+=',';
		        			}
		        			if(data.result<=4){
		        				ids+=data.id;	
		        			}
		        			
		        		});
		        		
		        		if(ids.length==0){
		        			layer.alert('正在己处理中或己通过');
		        			return;
		        		}
		        		
		        		$('#form').dialog({
			        	    title: '审核通过',
			        	    width: 500,
			        	    height: 380,
			        	    closed: false,
			        	    cache: false,
			        	    href: 'app/btRecord/form?page=0&id='+ids,
			        	    modal: true,
			        	    onClose:function(){
			        	    	$('#dat').datagrid('reload');
			        	    },
			        	    onDestroy:function(){
			        	    	$('#dat').datagrid('reload');
			        	    }
			        	});
		        	}else{
		        		layer.alert('请选择记录');
		        	}
		        }
		    },{
		        text:'拒绝',
		        iconCls:'icon-no',
		        handler:function(){
		        	var data=$('#dat').datagrid('getSelected');
		        	if(data&&data.id){
		        		
		        		if(data.result>0){
		        			layer.alert('己处理过');
		        			return;
		        		}
		        		
		        		$('#form').dialog({
			        	    title: '拒绝提币',
			        	    width: 500,
			        	    height: 380,
			        	    closed: false,
			        	    cache: false,
			        	    href: 'app/btRecord/form?page=1&id='+data.id,
			        	    modal: true,
			        	    onClose:function(){
			        	    	$('#dat').datagrid('reload');
			        	    },
			        	    onDestroy:function(){
			        	    	$('#dat').datagrid('reload');
			        	    }
			        	});
		        	}else{
		        		layer.alert('请选择记录');
		        	}
		        }
		    },{
		    	text:'刷新',
		    	iconCls:'icon-reload',
		        handler:function(){
		        	$('#dat').datagrid('reload');
		        }
		    }];
		    
		    
		    $('#dat').datagrid({
		    	loader:function(params,success,error){
		    		var pm={'pageNow':1,'pageSize':20,'sort':params.sort||'id','order':params.order||'desc'};
		    		if(params&&params.page){
		    			pm.pageNow=params.page;
		    		}
		    		if(params&&params.rows){
		    			pm.pageSize=params.rows;
		    		}
		    		if(params&&params.filterRules){
		    			$.each(JSON.parse(params.filterRules),function(index,item){
		    				pm[item.field]=item.value;
		    			})
		    		}
		    		$.post('app/btRecord/page',pm,function(r){
		    			success(r.result);
		    		},"json")
		    	},
		    	loadFilter: function(r){
		    		if (r){
		    			return {'rows':r.data,'total':r.total};
		    		}
		    	},
		    	onLoadSuccess:function(){
		    		$('#dat').datagrid('enableFilter');
		    	}
		    });
		    
		    //0待审核,1拒绝,2审核通过待挖矿 ,3提交失败,4挖矿中,5到帐失效,6己到帐
		    function showStatusTitle(value,row,index){
		    	var r='';
		    	switch(value){
		    	    case 0:r='审核中';break;
		    	    case 1:r='拒绝';break;
		    	    case 2:r='审核通过';break;
		    	    case 3:r='提交失败';break;
		    	    case 4:r='挖矿中';break;
		    	    case 5:r='到帐失效';break;
		    	    case 6:r='己到帐';break;
		    	}
		    	return r;
		    }
		  		   
		 		    
    </script>
</html>